package com.sz.biz.logistics.core.service.impl;

import com.sz.biz.common.constants.ModuleNames;
import com.sz.biz.logistics.core.entity.ServiceArea;
import com.sz.biz.logistics.core.service.ServiceAreaService;
import com.sz.common.base.constants.UserActions;
import com.sz.common.base.service.AbstractService;
import com.sz.common.core.service.PrincipalLogUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Function: ServiceAreaServiceImpl. <br>
 * Date: 2017年03月13日 17:04 <br>
 * Author: wentao.chang
 */
@Service
public class ServiceAreaServiceImpl extends AbstractService implements ServiceAreaService {
    /**
     * 新增
     *
     * @param list 新增的实体们
     * @return
     */
    @Override
    public void save(List<ServiceArea> list) {
        dao.batchInsert("ServiceAreaMapper.insert", list);
        //保存操作日志
        Map<String, Object> dataBackup = new HashMap<>();
        dataBackup.put("UPDATE_SERVICE", list);
        PrincipalLogUtils.addOperationLog(ModuleNames.BIZ, ModuleNames.BIZ_SERVICE, UserActions.UPDATE, "修改服务", dataBackup);
    }

    @Override
    public List<ServiceArea> findByRefId(int refId) {
        return dao.findForList("ServiceAreaMapper.findByRefId", refId, ServiceArea.class);
    }

    @Override
    public void deleteByServiceId(Integer serviceId) {
        dao.delete("ServiceAreaMapper.deleteByServiceId", serviceId);
    }
    @Override
    protected String getMapperNamespace() {
        return "ServiceAreaMapper";
    }
}
